Repository navigation
Conversation
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain: asynchronous DH can report success with a truncated shared secret, and modular-exponentiation error paths can free secret-bearing memory without wiping it.
4 open issues
What changed in this PR
Hardens wolfCrypt’s non-blocking RSA and DH operations and improves cleanup of sensitive arithmetic state.
Changes:
- Adds RSA blinding, RNG checks, and constant-time result encoding.
- Adds DH output-capacity and invalid shared-secret checks.
- Expands zeroization and regression coverage.
| File | Description |
|---|---|
wolfssl/wolfcrypt/rsa.h |
Stores the non-blocking blinding inverse. |
wolfcrypt/src/tfm.c |
Wipes arithmetic state and fixes encoder cleanup. |
wolfcrypt/src/rsa.c |
Hardens non-blocking private operations and encoding. |
wolfcrypt/src/dh.c |
Adds capacity and shared-secret validation. |
tests/unit-mcdc/test_rsa_whitebox.c |
Updates calls for the RNG parameter. |
tests/api/test_wolfmath.h |
Registers new arithmetic tests. |
tests/api/test_wolfmath.c |
Tests zeroization and Montgomery reduction. |
tests/api/test_rsa.h |
Registers the non-blocking RSA test. |
tests/api/test_rsa.c |
Tests RNG requirements, results, and cleanup. |
tests/api/test_dh.h |
Registers the short-buffer test. |
tests/api/test_dh.c |
Tests short buffers and invalid agreements. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
fp_exptmod_nb()now wipes its ladder and digit state when an exponentiation ends or fails. Before, it left the RSA private result in the caller's non-blocking context. (F-15332)wc_RsaFunctionNonBlock()writes the result with the constant-time fixed-length encoder that the blocking path uses. (F-19389)WC_RSA_BLINDING, as in the blocking path, with blinding run as resumable steps within the time budget. Fastmath and SP non-blocking private operations both returnMISSING_RNG_Ewhen there is no RNG.RsaNbgains twomp_ints and a state field in fastmath builds with blinding. (F-19390)_fp_exptmod_ct(),_fp_exptmod_nct()andfp_to_unsigned_bin()wipe their temporaries before freeing them. Thefp_to_unsigned_bin_len()fallback no longer reads its copy after freeing it. (F-17661, F-19061)Resolves F-15332, F-19389, F-19390, F-15169, F-17661, F-19061.
Testing
New and extended tests are in
tests/api(test_rsa.c,test_dh.c,test_wolfmath.c). Where the effect can be observed, each test fails without its fix. There is also a test comparing constant-time and regular Montgomery reduction, since that reduction does the new unblinding.WC_RSA_NONBLOCK_TIME), SP non-blocking RSA and DH, and fastmath--disable-sp: ASan/UBSan.--enable-all,--enable-wpas, and--enable-cryptonlywithout RSA or DH, with-Werror.